package org.example.project_end.service.serviceiml;

import org.example.project_end.entity.User;
import org.example.project_end.mapper.UserMapper;
import org.example.project_end.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceIml implements UserService {
    @Autowired
    UserMapper userMapper;
    public boolean Login(String username, String password) {
        User user=userMapper.selectUsername(username);
        if(user!=null){
            if(password.equals(user.getPassword())){
                return true;
            }
            else {
                return false;
            }
        }
        else {
            return false;
        }

    }
    public boolean register(String username, String password, String phone,String email) {
        userMapper.insertUser(username,password,phone,email);
        User user=userMapper.selectUsername(username);
        if (user!=null){
            return true;
        }
        else {
            return false;
        }
    }
}
